package com.geely.controller;

import java.util.List;
import com.geely.model.Record;
import com.jfinal.core.Controller;

public class RecordController extends Controller 
{
	private String pageAdd="/Record/add.html";
	private String pagequery="/Record/query.html";
	public void index()
	{
		//int sum=Record.dao.getCount();
		setAttr("record", Record.dao.getAllRecord());
		render("/Record/index.html");
		
	}
	
	public void add()
	{
//		List<Record> record=Record.dao.find("select * from record");
//		setAttr("record",record);
		render(pageAdd);
	}
	
	public void edit() 
	{
		Record record=Record.dao.findById(getPara("id"));
		setAttr("record", record);
		render("/Record/edit.html");
	}
	public void delete() 
	{
		Record.dao.deleteById(getPara("id"));  
        index();
	}
	public void update() 
	{
		Record record=getModel(Record.class);
		record.update();
		redirect("/record");

	}
	public void submit(){
		Record record=getModel(Record.class);
		record.save();
		redirect("/record");
	}
	public void list()
	{
		String stationName=getPara("stationName");
		setAttr("list", Record.dao.Query(stationName));
		redirect(pagequery);
	}
}
